<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="com.liferay.portal.service.ListTypeServiceUtil"%>
<%@page import="com.liferay.portal.model.ListType"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@page import="com.crossriver.crgis.database.model.Property_Information"%>
<%@ page import="com.crossriver.crgis.database.model.Application_C_of_O" %>
<%@ page import="com.crossriver.crgis.cofo.util.ApplicationCofOConstants" %>
<%@ include file="/init.jsp"%>
<%@page import="com.liferay.portal.model.Country"%>
<%@page import="com.liferay.portal.service.CountryServiceUtil"%>
<%@page import="com.crossriver.crgis.database.service.persistence.Application_C_of_OUtil"%>
<script src="<%=request.getContextPath()%>/js/jquery-1.6.2.js" language="javascript" type="text/javascript"></script>

<%
Property_Information propInfo =
		(Property_Information)request.getAttribute(
					ApplicationCofOConstants.PROPERTY_INFO_SESSION_ATTR); 
Application_C_of_O applicatn = 
	Application_C_of_OUtil.findByPrimaryKey(propInfo.getApplicationId());

Application_C_of_O appl =
	(Application_C_of_O)request.getAttribute(
			ApplicationCofOConstants.APPL_C_OF_O_SESSION_ATTR);

%>

<liferay-portlet:actionURL name="savePropInformation" var="savePropInformation"></liferay-portlet:actionURL>

<portlet:defineObjects />

<portlet:resourceURL var="ajaxCallResourceURL" />
<aui:form  action="<%=savePropInformation.toString() %>"   method="post" name="savePropInformation_fm">
<% String app = applicatn.getApplication(); %>
 <div id="main">
	<%
	if("certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Certificate Of Occupancy</h1>
	<%
	}else if("re-certification".equalsIgnoreCase(app)){
	%>
	<h1>Application for Re-Certificate Of Occupancy</h1>
	<%
	}else {
	%>
	<h1>Application for State Land</h1>
	<%
	}
	%>

	<div class="content">
	
	<liferay-ui:error key="property-type-mandatory" message="property-type-mandatory" />
	<liferay-ui:error key="block-no-mandatory" message="block-no-mandatory" />
	<liferay-ui:error key="plotno-is-mandatory" message="plotno-is-mandatory" />
	<liferay-ui:error key="area-is-mandatory" message="area-is-mandatory" />
	<liferay-ui:error key="city-is-mandatory" message="city-is-mandatory" />
	<liferay-ui:error key="state-is-mandatory" message="state-is-mandatory" />
	<liferay-ui:error key="land-location-is-mandatory" message="zone-layout-is-mandatory" />
	<liferay-ui:error key="country-is-mandatory" message="country-is-mandatory" />
	<liferay-ui:error key="property-type-is-mandatory" message="property-type-is-mandatory" />
	<liferay-ui:error key="property-type-is-mandatory" message="property-type-is-mandatory" />
	<liferay-ui:error key="allocation-made-is-mandatory" message="allocation-made-is-mandatory" />
	<liferay-ui:error key="assigned-to-you" message="assigned-to-you" />
	<liferay-ui:error key="land-use-is-mandatory" message="land-use-is-mandatory" />
	<liferay-ui:error key="use-purpose-is-mandatory" message="use-purpose-is-mandatory" />
	<liferay-ui:success key="property-information-save-success" message="property-information-save-success"></liferay-ui:success>
	
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
			<td width="15%" valign="top">
				<aui:input name="applicationId" type="hidden" value="<%= propInfo.getApplicationId() %>"></aui:input>
				<aui:input name="buttonClicked" type="hidden" value=""></aui:input>
				<table width="100%" id="steps" cellpadding="0" cellspacing="0">
       		<tr><td valign="middle" align="center">STEP 1</td></tr>
       		<tr><td valign="middle" align="center">STEP 2</td></tr>
	        <tr><td valign="middle" align="center">STEP 3</td></tr>
          <tr><td valign="middle" align="center" class="current">STEP 4</td></tr>
          <tr><td valign="middle" align="center">STEP 5</td></tr>
          <tr><td valign="middle" align="center">STEP 6</td></tr>
          <tr><td valign="middle" align="center">STEP 7</td></tr>
          <tr><td valign="middle" align="center">STEP 8</td></tr>                               
       	</table>
			</td>
			<td width="85%" valign="top">
				<table width="100%" id="mainform">
				<tr><td class="title" colspan="3">Property Information</td></tr>
				
				<tr>
					<td colspan="3" align="right" style="padding-right: 20px">
						<hr>
						<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
             	
              
             	<aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
            	<aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
             	<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
					</td>
				</tr>
				
				<tr>
					<td colspan="3"><br>
					
					
					<%
					List<ListType> propTypes = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.property_type");
					
					%>
					
					<aui:select name="propertyType" label="Property Type<span class='mandatoryfld'>*</span>">
						<option style="font-style: italic; color: #A0A0A4" value="">--Please Select Type--</option>
				  	
				  	<%
				  	String propType = propInfo.getPropertyType();
				  	for(int i=0; i<propTypes.size(); i++){
				  		ListType _propType = propTypes.get(i);
				  	%>	
				  	<aui:option selected="<%= _propType.getName().equalsIgnoreCase(propType)  %>" 
		                  		value="<%=_propType.getName() %>"><%=_propType.getName()  %></aui:option>
				  	<%
				  	}
				  	%>
					</aui:select>
					
					</td>
				</tr>
				
				<tr>
					<td width="33%"><br>
						<aui:input label="Block Number<span class='mandatoryfld'>*</span>" 
	           	inlineLabel=""
	           	name="blockNo" 
	           	value="<%= propInfo.getBlockNo() %>"
	           	helpMessage=""></aui:input>
		    	</td>
		      <td width="33%"><br>
		      	<aui:input label="Plot Number<span class='mandatoryfld'>*</span>" name="plotNo" 
            	value="<%= propInfo.getPlotNo() %>"
              ></aui:input>
		     	</td>
		     	<td width="33%"><br>
		      		&nbsp;
		     	</td>
		  	</tr>
		  	 
		  	<tr>
					<td><br>
<%-- 	         	<aui:column columnWidth="50"> --%>
                  	<aui:select style="width:130px" name="country" label="Country<span class='mandatoryfld'>*</span>" 	
 				  		helpMessage="" onchange=''  >
 				  		<option label="" value="" >  </option>
                  	
 				  		<%
 				  		String country = "";
 				  		if (propInfo== null  
 				  				|| propInfo.getCountry() == null
 				  				|| propInfo.getCountry().equalsIgnoreCase("") ){
 				  			
 				  		}else{
 				  			country =  propInfo.getCountry();
 				  		}
 				  		
		                List<Country> countries = CountryServiceUtil.getCountries();
		                
		                for (Country _country : countries) {
		                	if("Nigeria".equalsIgnoreCase(_country.getName())){
		                %> 
		                  		<aui:option selected="<%= _country.getName().equalsIgnoreCase(country) %>" 
		                  		value="<%=_country.getName() %>"><%=_country.getName()  %></aui:option>
		 				<%
		                	}
		                }
		 				%>
                 	</aui:select>				  	
<%--                  </aui:column> --%>
		     	</td>
		     	<td>
		     	<br>
	           	<%
					List<ListType> states = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.state");
					
					%>
					
					<aui:select style="width:130px" name="state"  
						 label="State<span class='mandatoryfld'>*</span>" listType="dropdownlist" >
							<option value="">-Select State-</option>
				  	
				  	<%
				  	String stateOfOriginS = propInfo.getState();
					
				  	for(int i=0; i<states.size(); i++){
				  		ListType _states = states.get(i);
				  		if("CROSS RIVER".equalsIgnoreCase(_states.getName())){
				  	%>	
				  	<aui:option selected="<%=  _states.getName().equalsIgnoreCase(stateOfOriginS) %>" 
		                  		value="<%=_states.getName() %>"><%=_states.getName()  %></aui:option>
				  	<%
				  		}
				  	}
				   
				  	%>
					</aui:select>
		     	</td>
		      <td>
		      <br>
		       
   	      	 <%
   	      	 		List<ListType> lga = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.lga.cross river" );
					
					%>
					
					<aui:select style="width:130px" name="city"  id="city"
						 label="Local Government<span class='mandatoryfld'>*</span>" listType="dropdownlist" >
							<option value="">-Select LGA-</option>
				  	
				  	<%
				  	String LGAS = propInfo.getCity();
				  	for(int i=0; i<lga.size(); i++){
				  		ListType _lga = lga.get(i);
				  	%>	
				  	<aui:option selected="<%=  _lga.getName().equalsIgnoreCase(LGAS) %>" 
		                  		value="<%=_lga.getName() %>"><%=_lga.getName()  %></aui:option>
				  	<%
				  	}
				  	%>
					</aui:select>
						

		    	</td>
		    </tr>		
		  	
		  	<tr>
		     	<td><br>
		      	<aui:input label="Area<span class='mandatoryfld'>*</span>" 
	          	value="<%= propInfo.getArea() %>"
	            name="area"/>
	       	</td>
	       	<td><br>
	       	
	       						
					<%
					List<ListType> uoms = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.uom");
					
					%>
					
					<aui:select style="width:130px"name="unitOfMeasurement" label="Unit of Measurement">
						<option style="font-style: italic; color: #A0A0A4" value="">--Please Select UOM--</option>
				  	
				  	<%
				  	String uom = propInfo.getUom();
				  	for(int i=0; i<uoms.size(); i++){
				  		ListType _uom = uoms.get(i);
				  	%>	
				  	<aui:option selected="<%= _uom.getName().equalsIgnoreCase(uom)  %>" 
		                  		value="<%=_uom.getName() %>"><%=_uom.getName()  %></aui:option>
				  	<%
				  	}
				  	%>
					</aui:select>
					
		     	</td>
		     	<td>&nbsp;
		     		
		     	</td>
	     	</tr>
	     	
	     	<tr>
					<td colspan="3"><br>
							<%
	List<ListType> layoutName = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.layout");
	
	%> 
	<aui:select name="landLocation"  label="Zone/Layout<span class='mandatoryfld'>*</span>">
		<option style="font-style: italic; color: #A0A0A4" value="">--Please Select Layout--</option>
  	
  	<%
  	String layoutN = propInfo.getLandLocation();
  	for(int i=0; i<layoutName.size(); i++){
  		ListType _layoutName = layoutName.get(i);
  	%>	
  	<aui:option  selected="<%= _layoutName.getName().equalsIgnoreCase(layoutN) %>"
                		value="<%=_layoutName.getName() %>"><%=_layoutName.getName()  %></aui:option>
  	<%
  	}
  	%>
	</aui:select>
					</td>
				</tr>
				
				<tr>
					<td colspan="3"><br>
						<aui:input name="otherUsefulInformation" label="Please provide additional useful information that may assist the agency in 
						processing your application."
						value="<%= propInfo.getOtherUsefulInformation() %>"
						type="textarea" style="width:400px"></aui:input>
					</td>
				</tr>
				
				<tr>
					<%
						if("re-certification".equalsIgnoreCase(app)){
					%>
						<td colspan="3"><br>
						<label class="aui-field-label" for="<portlet:namespace/>origCofODate">
							What is the date on the Original Certificate of Occupancy (CofO)?
						</label>
						<%
							Calendar cal = CalendarFactoryUtil.getCalendar();
							if (propInfo.getOrigCofODate() != null){
								cal.setTime(propInfo.getOrigCofODate());
								//cal.setTime(individual.getDateOfBirth().getTime()));
							}
							Calendar current = CalendarFactoryUtil.getCalendar();
							%>	
		               <liferay-ui:input-date  formName="origCofODate" 
					      dayParam="origCofODateDay"
					      dayValue="<%= cal.get(Calendar.DATE) %>"
					      disabled="<%= false %>"
					      firstDayOfWeek="<%= cal.getFirstDayOfWeek() - 1 %>"
					      monthParam="origCofODateMonth"
					      monthValue="<%= cal.get(Calendar.MONTH) %>"
					      yearParam="origCofODateYear"
					      yearValue="<%= cal.get(Calendar.YEAR) %>"
					      yearRangeStart="<%= 1979 %>"
					      yearRangeEnd="<%= current.get(Calendar.YEAR)   %>"
					    />
						</td>
					<%
				}
					%>
					


						
					</tr>
					
					<tr>
						<td colspan="3"><br>
							<aui:select name="allocationMadeToYou" label="Was the original allocation made to you?<span class='mandatoryfld'>*</span>">
								<option value="">-Please Select An Option-</option>
								<aui:option value="No" selected='<%=propInfo.getAllocationMadToYou().equalsIgnoreCase("No")%>'>No</aui:option>
								<aui:option value="Yes" selected='<%=propInfo.getAllocationMadToYou().equalsIgnoreCase("Yes")%>'>Yes</aui:option>
							</aui:select>
						</td>
					</tr>
					
					<%
					%>
					
					<tr>
						<td colspan="3"><br>
							<aui:select name="assignedToYou" label="Do you have an assignment?<span class='mandatoryfld'>*</span>">
								<option value="">--Please Select An Option--</option>
								<aui:option value="No" selected='<%=propInfo.getAssignedToYou().equalsIgnoreCase("No")%>'>No</aui:option>
								<aui:option value="Yes" selected='<%=propInfo.getAssignedToYou().equalsIgnoreCase("Yes")%>'>Yes</aui:option>
							</aui:select>
						</td>
					</tr>
					
					<tr>
						<td><br>
						
						<%
						List<ListType> useTypes = ListTypeServiceUtil.getListTypes("com.teqbridgeltd.liferay.model.land_use");
						
						%>
						<aui:select style="width:140px" name="useType" label="Specify Land Use<span class='mandatoryfld'>*</span>"
								onChange='<%= renderResponse.getNamespace() + "getPropertyUse(this);" %>'>
							<option value="">-Please Select Land Use-</option>
					  	
					  	<%
					  	String useType = appl.getLandUseType();
					  	for(int i=0; i<useTypes.size(); i++){
					  		ListType _useType = useTypes.get(i);
					  	%>	
					  	<aui:option selected="<%= _useType.getName().equalsIgnoreCase(useType)  %>" value="<%=_useType.getName() %>"><%=_useType.getName()  %></aui:option>
					  	<%
					  	}
					  	%>
						</aui:select>
						
						</td>
						  
						<td ><br>
							<aui:select style="width:140px" name="purpose" label="Specify Purpose<span class='mandatoryfld'>*</span>"  />
							<input id="purposeSelected" type="hidden" value="<%= applicatn.getLandUsePurpose() %>"></input>
						
						
<script>
try{
	var purpose=document.getElementById('<portlet:namespace/>purpose');
	var purposeSelected=document.getElementById('purposeSelected').value;
	
	var selected = document.createElement('option'); 
	selected.appendChild(document.createTextNode(purposeSelected)); 
	purpose.appendChild(selected);
	//alert(useType);
	}
	catch (ex){
		alert(ex);
		}
</script>	
						</td>
						<td>&nbsp;
							
						</td>
					</tr>
					
					<tr>
						<td colspan="3" align="right" style="padding-right: 20px">
							<hr>
							<aui:button type="button" value="Exit Application" onClick="exitApplication();"></aui:button>
             	
              
             	<aui:button type="submit" value="Save" onClick="setButtonClicked('btnSave');" ></aui:button>
            	<aui:button type="submit" value="Save and Continue" onClick="setButtonClicked('btnSaveAndContinue');" ></aui:button>
             	<aui:button type="button" value="Cancel Application" onClick="confirmPost()"></aui:button>
						</td>
					</tr>
				
				</table>
			</td>
			</tr>
		</table>
	</div>
</div>

  <script type="text/javascript">
	function setButtonClicked(id)
	{
	   // alert(id);
	   document.<portlet:namespace/>savePropInformation_fm.<portlet:namespace/>buttonClicked.value=id;
	  // alert(document.<portlet:namespace/>quick_add_account_fm.<portlet:namespace/>buttonClicked.value);
	    //document.getElementById('jspPage').value=id;
	}

	</script>
</aui:form>

	<liferay-portlet:actionURL name="exitApplication" var="exitApplication"></liferay-portlet:actionURL>
	<form name="<portlet:namespace/>exitApplication_fm" method="post"	id="<portlet:namespace/>exitApplication_fm" action="<%=exitApplication.toString()%>"></form>
	<script type="text/javascript">
	<!--
	function exitApplication()
	{
		document.forms["<portlet:namespace/>exitApplication_fm"].submit();
	}
	//-->
	</script>

<script type="text/javascript">
<!--
	function confirmPost()
	{
	var agree=confirm("Cancelling the process will delete the record you have entered into the portal for this application. Do you want to proceed?");
	if (agree){
		document.forms["<portlet:namespace/>deleteApplication_fm"].submit();
		return true ;
	}
	else{
		return false ;
	}
	}
	
	function <portlet:namespace />getPropertyUse(obj){
		ajaxcallToGetPropertyUse(obj.value);
	}
	
	function <portlet:namespace />getState(obj){
		ajaxcallToGetState(obj.value);
	}
	
	function <portlet:namespace />getLGA(obj){
		ajaxcallToGetLGA(obj.value);
	}
	
//-->
</script>

<portlet:resourceURL var="fetchdataAction">
    <portlet:param name="fetchdataAction" value="/view.jsp" />
</portlet:resourceURL>
<script>
    //$("#id1").hide("slow");
    function ajaxcallToGetPropertyUse(landUse)
    {
        $.ajax({
           type: "POST",
           url: "<%= fetchdataAction %>",
           data:  {
				<portlet:namespace />landUse: landUse,
				<portlet:namespace />queryType: 'landUse',
			},
			dataType: "json",
           success: function(msg){

        	var message = msg;
        						
			var stateId = message.stateId;
			
			
			document.getElementById('<portlet:namespace />purpose').options.length = 0;
			var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
			var state = document.createElement('option');  
			state.appendChild(document.createTextNode("-Please specify purpose-"));
			oFieldSelect.appendChild(state);
			
			
			if (message) {
				  for( i=1; i<=stateId; i++){
				    var param = "param_" + i;
					//alert(param);
					var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
					var state = document.createElement('option'); 
					
		
					//state.appendChild(document.createTextNode(message." + param + ")); 
					state.appendChild(document.createTextNode(message[param]));
					oFieldSelect.appendChild(state); 
					  
				  }
				}
			else {
				alert('no data back from server');
			}
           }
         });
    }
 
    function ajaxcallToGetState(states)
    {
        $.ajax({
           type: "POST",
           url: "<%= fetchdataAction %>",
           data:  {
				<portlet:namespace />landUse: states,
				<portlet:namespace />queryType: 'states',
			},
			dataType: "json",
           success: function(msg){

        	var message = msg;
        						
			var stateId = message.stateId;
			
			
			document.getElementById('<portlet:namespace />city').options.length = 0;		
			document.getElementById('<portlet:namespace />state').options.length = 0;
			var oFieldSelect= document.getElementById('<portlet:namespace />state');
			var state = document.createElement('option');  
			state.appendChild(document.createTextNode("-Please specify State-"));
			oFieldSelect.appendChild(state);
			
			document.getElementById('<portlet:namespace />city').options.length = 0;
			
			
			if (message) {
				  for( i=1; i<=stateId; i++){
				    var param = "param_" + i;
					//alert(param);
					var oFieldSelect= document.getElementById('<portlet:namespace />state');
					var state = document.createElement('option'); 
					
		
					//state.appendChild(document.createTextNode(message." + param + ")); 
					state.appendChild(document.createTextNode(message[param]));
					oFieldSelect.appendChild(state); 
					  
				  }
				}
			else {
				alert('no data back from server');
			}
           }
         });
    }
 
    
    function ajaxcallToGetLGA(lga)
    {
        $.ajax({
           type: "POST",
           url: "<%= fetchdataAction %>",
           data:  {
				<portlet:namespace />landUse: lga,
				<portlet:namespace />queryType: 'lga',
			},
			dataType: "json",
           success: function(msg){

        	var message = msg;
        						
			var stateId = message.stateId;
			
			document.getElementById('<portlet:namespace />city').options.length = 0;

			var oFieldSelect= document.getElementById('<portlet:namespace />city');
			var state = document.createElement('option');  
			state.appendChild(document.createTextNode("-Please specify City-"));
			oFieldSelect.appendChild(state);
			
			if (message) {
				  for( i=1; i<=stateId; i++){
				    var param = "param_" + i;
					//alert(param);
					var oFieldSelect= document.getElementById('<portlet:namespace />city');
					var state = document.createElement('option'); 
					
		
					//state.appendChild(document.createTextNode(message." + param + ")); 
					state.appendChild(document.createTextNode(message[param]));
					oFieldSelect.appendChild(state); 
					  
				  }
				}
			else {
				alert('no data back from server');
			}
           }
         });
    }
 

</script>

<aui:script>
		
	Liferay.provide(window,
		'<portlet:namespace />getStates',
		function(countryName) {
	var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />countryName: countryName,
							<portlet:namespace />queryType: 'states',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
								
						document.getElementById('<portlet:namespace />city').options.length = 0;		
						document.getElementById('<portlet:namespace />state').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-select a state-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
							 for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option'); 
									
									if('CROSS RIVER' == message[param]){
										//state.appendChild(document.createTextNode(message." + param + ")); 
										state.appendChild(document.createTextNode(message[param]));
										oFieldSelect.appendChild(state); 
									}

								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />state');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide


	Liferay.provide(window,
		'<portlet:namespace />getLGA',
		function(stateName) {
			var A = AUI();
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />stateName: stateName,
							<portlet:namespace />queryType: 'LGA',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
						document.getElementById('<portlet:namespace />city').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-select a LGA-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
								  for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option'); 
									
						
									//state.appendChild(document.createTextNode(message." + param + ")); 
									state.appendChild(document.createTextNode(message[param]));
									oFieldSelect.appendChild(state); 
									  
								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />city');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide
	
	Liferay.provide(window,
		'<portlet:namespace />getPropertyUse1',
		function(landUse) {
			var A = AUI();
			alert(landUse.value);
			var url = '<%= ajaxCallResourceURL.toString() %>';
				A.io.request(
					url,
					{
						//data to be sent to server
						data: {
							<portlet:namespace />landUse: landUse.value,
							<portlet:namespace />queryType: 'landUse',
						},
						dataType: 'json',

						on: {
							failure: function() {
							},

							success: function(event, id, obj) {
								var instance = this;


								//JSON Data coming back from Server
								
								var message = instance.get('responseData');
								
								var stateId = message.stateId;
								
						document.getElementById('<portlet:namespace />purpose').options.length = 0;
						var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Please specify purpose-"));
									oFieldSelect.appendChild(state);
							if (stateId>0){
								if (message) {
								  for( i=1; i<=stateId; i++){
								    var param = "param_" + i;
									//alert(param);
									var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option'); 
									
						
									//state.appendChild(document.createTextNode(message." + param + ")); 
									state.appendChild(document.createTextNode(message[param]));
									oFieldSelect.appendChild(state); 
									  
								  }
								}
								else {
									alert('no data back from server');
								}
								}
							else{
								var oFieldSelect= document.getElementById('<portlet:namespace />purpose');
									var state = document.createElement('option');  
									state.appendChild(document.createTextNode("-Not available-"));
									oFieldSelect.appendChild(state); 
								}
							}

						}
					}

				); //END of io Request

		},
		['aui-io']
	);  //End of Provide
	
</aui:script>

<liferay-portlet:actionURL name="deleteApplication" var="deleteApplication"></liferay-portlet:actionURL>
 <aui:form action="<%=deleteApplication.toString() %>" method="post" name="deleteApplication_fm">
  	<aui:input name="applicationId" type="hidden" value="<%= propInfo.getApplicationId() %>"></aui:input>
 </aui:form>
 
 